package ch.silviowangler.hockeygame.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * @author Silvio Wangler
 * @since 1.0
 *        Date: 27.04.2010
 */

@Entity
@Table(name = "hockey_user")
public class User extends BaseEntity {

    private String nickname;
    private String firstname;
    private String lastname;
    private byte[] password;

    public User(String firstname, String lastname, String nickname, byte[] password) {
        this.firstname = firstname;
        this.lastname = lastname;
        this.nickname = nickname;
        this.password = password;
    }


    @Column(nullable = false, unique = true, length = 20, name = "nickname")
    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    @Column(nullable = false, length = 30, name = "firstname")
    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    @Column(nullable = false, length = 200, name = "pwd")
    public byte[] getPassword() {
        return password;
    }

    public void setPassword(byte[] password) {
        this.password = password;
    }

    @Column(nullable = false, length = 50, name = "lastname")
    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("User");
        sb.append("{nickname='").append(nickname).append('\'');
        sb.append(", firstname='").append(firstname).append('\'');
        sb.append(", lastname='").append(lastname).append('\'');
        sb.append(", password=").append(password == null ? "null" : "");
        for (int i = 0; password != null && i < password.length; ++i)
            sb.append(i == 0 ? "" : ", ").append(password[i]);
        sb.append('}');
        return sb.toString();
    }
}
